﻿namespace SmallGeo;

/// <summary>
/// 表示点与线段的分析结果
/// </summary>
public struct PointWithLineSegmentResult
{
    public EnumPointWithLineSegment Flag { get; set; }
    public bool IsOnLine() => Flag == EnumPointWithLineSegment.IsOnEdge || Flag == EnumPointWithLineSegment.IsOnCorner;
    public bool IsOutLine() => (Flag & EnumPointWithLineSegment.IsOut) > 0 || (Flag & EnumPointWithLineSegment.IsOnExtensionLine) > 0;

    /// <summary>
    /// 当点近似在线上或线的延长线上时, 与线的交点
    /// </summary>
    public Vector2d CrossPoint { get; set; }

    /// <summary>
    /// 点更靠近线段的哪一边(0: 起点, 1: 终点)
    /// </summary>
    public int PointIndex { get; set; }
}
